<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>解析url参数的方法</title>
</head>
<body>
    
    <script>
        
        let search = '?id=sxcdzzxssww_+&user=wangshuo&age=28';

        function paramsToObj (search) {
            const obj = {};
            search.match(/([^?=&]+)(=([^&]*))/g).forEach(element => {
                const ary = element.split('=');
                obj[ary[0]] = ary[1];
            });
            return obj;
        }

        console.log(paramsToObj(search))
    </script>
</body>
</html>